/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { message } from 'antd';

export type ToastStatus = 'success' | 'error';
export interface Toast {
  success: string | boolean;
  error: string | boolean;
}

/**
 * @descriptions 展示信息
 */
export function showMessage(msg: string, status: ToastStatus, toast?: Toast) {
  const toastFill = {
    success: true,
    error: true,
    ...toast,
  };
  let toastMsg = toastFill[status];
  if (toastMsg) {
    toastMsg = typeof toastMsg === 'boolean' ? msg : toastMsg;
  }
  if (!toastMsg) return;
  message[status](toastMsg);
}
